package panel.media
{
	import assists.Lang;
	import assists.URI;
	import assists.media.SoundMedia;
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.media.Sound;
	
	import inerface.IMediaPanel;
	
	import main.ClientConstants;
	
	public class MediaPanel extends Sprite implements IMediaPanel
	{
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _lang:Lang;
		
		private var _sound:SoundMedia;

		private var _process:MediaPlayProcess;
		private var _scrollText:TextScrollAuto;
		public function MediaPanel()
		{
			super();
		}
		
		public function init(stage:Stage, loader:ResourceLoader, lang:Lang,uri:URI = null):void
		{
			_stage = stage;
			_loader = loader;
			_lang = lang;
			
			_sound = new SoundMedia();
//			layoutUI();
//			_sound.onUpdate = _process.update;
			
		}
		
		public function get soundMedia():SoundMedia
		{
			return _sound;
		}
		
		public function playSound(value:String):void
		{
			_sound.loadSound(value);
		}
		
		public function startScrollText(showStr:String,speed:Number,showWid:int,showHei:int):void
		{
			return;
			if(!_scrollText)
			{
				_scrollText = new TextScrollAuto();
				_scrollText.x = _stage.stageWidth * 0.05;
				_scrollText.y = 200;
				this.addChild(_scrollText);
			}
			_scrollText.playScroll(showStr,speed,showWid,showHei);
		}
		
		private function layoutUI():void
		{
			var btnGroup:MediaBtnGroup = new MediaBtnGroup();
			btnGroup.init(_loader,_stage);
			btnGroup.onControlMedia = _sound.onControllSound;
			btnGroup.y = _stage.stageHeight - _stage.stageHeight * ClientConstants.HOME_DOWN_PER - btnGroup.height;
			this.addChild(btnGroup);
			
			_process = new MediaPlayProcess();
			_process.changeProcss = _sound.updateProcess;
			_process.lindeWid = _stage.stageWidth - btnGroup.width;
			_process.init(_loader,_stage);
			_process.y = btnGroup.y;
			_process.x = btnGroup.x + btnGroup.width;
			this.addChild(_process);
			
		}
		
		public function clear():void
		{
			_sound.clear();
		}
	}
}